import dayjs from 'dayjs'
import weekday from 'dayjs/plugin/weekday'
import 'dayjs/locale/zh-cn'
import './styles/main.css'
import '@/utils/websocket'
import '@imengyu/vue3-context-menu/lib/vue3-context-menu.css'

dayjs.locale('zh-cn') // 设置 dayjs 语言
dayjs.extend(weekday) // 设置一周起始位周一

import { ViteSSG } from 'vite-ssg'
import { setupLayouts } from 'virtual:generated-layouts'

import { routes } from 'vue-router/auto-routes'
import App from './App.vue'
import type { UserModule } from './types'

import '@unocss/reset/tailwind.css'
import 'uno.css'
import 'element-plus/theme-chalk/src/message.scss'
import 'element-plus/theme-chalk/src/message-box.scss'
import 'element-plus/theme-chalk/src/notification.scss'
import 'element-plus/theme-chalk/src/loading.scss'
import 'element-plus/dist/index.css'

// https://github.com/antfu/vite-ssg
export const createApp = ViteSSG(
  App,
  {
    routes: setupLayouts(routes),
    base: import.meta.env.BASE_URL,
  },
  (ctx) => {
    // install all modules under `modules/`
    Object.values(
      import.meta.glob<{ install: UserModule }>('./modules/*.ts', { eager: true }),
    ).forEach((i) => i.install?.(ctx))
    Object.values(
      import.meta.glob<{ install: UserModule }>('./directives/*.ts', { eager: true }),
    ).forEach((i) => i.install?.(ctx))
  },
)
